package com.example.hongyu.avtt.ui.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.example.hongyu.avtt.R;
import com.example.hongyu.avtt.model.Picture;
import com.example.hongyu.avtt.ui.base.BaseAdapter;
import com.example.hongyu.avtt.ui.base.BaseViewHolder;

import java.util.List;

import butterknife.BindView;

public class PictureListAdapter extends BaseAdapter<Picture, PictureListAdapter.ViewHolder> {

    public PictureListAdapter(Context context, List<Picture> list) {
        super(context, list);
    }

    @Override
    public int getItemView() {
        return R.layout.picture_list_item_view;
    }

    @Override
    protected ViewHolder getViewHolder(View itemView) {
        return new ViewHolder(itemView);
    }
    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        super.onBindViewHolder(holder, position);
        Picture picture= mList.get(position);
//        holder.name.setText(picture.getName());

        Glide.with(mContext)
                .load(picture.getUrl())
                .placeholder(R.mipmap.no_image)
                .diskCacheStrategy(DiskCacheStrategy.SOURCE )
                .crossFade().into(holder.icon);

    }
    static class ViewHolder extends BaseViewHolder {

//        @BindView(R.id.item_name)
//        TextView name;
        @BindView(R.id.item_icon)
        ImageView icon;




        public ViewHolder(View itemView) {
            super(itemView);
        }
    }
   
}
